<?php
defined('RESOLUTION_ROOT') || define('RESOLUTION_ROOT',dirname(__DIR__) . DIRECTORY_SEPARATOR );

Resolution_Autoloader::Register();

class Resolution_Autoloader
{
    /**
     * Register the Autoloader with SPL
     */
    public static function Register() {
        if (function_exists('__autoload')) {
            //    Register any existing autoloader function with SPL, so we don't get any clashes
            spl_autoload_register('__autoload');
        }
        //    Register ourselves with SPL
        return spl_autoload_register(array('Resolution_Autoloader', 'Load'));
    }


    /**
     * Autoload a class identified by name
     * @param    string    $pClassName        Name of the object to load
     */
    public static function Load($pClassName){
        if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'Resolution') !== 0)) {
            return FALSE;
        }

        $pClassFilePath = RESOLUTION_ROOT .
            str_replace('\\',DIRECTORY_SEPARATOR,$pClassName) .
            '.class.php';

        if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
            return false;
        }
        require($pClassFilePath);
    }

}